//
//  SelectDestinationVC.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/12/26.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "SelectDestinationVC.h"
#import "NearbyCityVC.h"
@interface SelectDestinationVC ()

@end

@implementation SelectDestinationVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    CLLocation *location = [LocationManager sharedManager].currentLocation;

    if (!location) {
        
        [ActivityIndicatorView hideHUDAddedTo:self.view];
        [self setupWithNavTitles:@[MYLocalizedString(@"DESTINATION_RECOMMED", nil),MYLocalizedString(@"DESTINATION_ALL", nil)] PageVcClass:@[[NSClassFromString(@"DestinationVC") new],[NSClassFromString(@"AllCityVC") new]]];
        //
        return ;
    }
    
    CLLocationCoordinate2D coor = transformFromGCJToWGS(location.coordinate, nil);
    
    [ActivityIndicatorView showHUDAddedTo:self.view backgroundColor:[UIColor whiteColor]];
    @weakify(self);
    [NetAPIManager getRecommendScenicWithLocation:coor andBlock:^(City *locationcity, NSError *error) {
        
        @strongify(self);
        [ActivityIndicatorView hideHUDAddedTo:self.view];
        
        if (locationcity) {
            
            NearbyCityVC *nearVC = [NearbyCityVC new];
            
            locationcity.isGPS = YES;
            nearVC.GPSCity = locationcity;
            
            [self setupWithNavTitles:@[MYLocalizedString(@"DESTINATION_RECOMMED", nil),MYLocalizedString(@"DESTINATION_NEARBY", nil),MYLocalizedString(@"DESTINATION_ALL", nil)] PageVcClass:@[[NSClassFromString(@"DestinationVC") new],nearVC,[NSClassFromString(@"AllCityVC") new]]];
        } else {
            
            [self setupWithNavTitles:@[MYLocalizedString(@"DESTINATION_RECOMMED", nil),MYLocalizedString(@"DESTINATION_ALL", nil)] PageVcClass:@[[NSClassFromString(@"DestinationVC") new],[NSClassFromString(@"AllCityVC") new]]];
        }
        
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
